require './test/test_helper'

# Public: Tests the Pyro helpers.
#
# Example
#
#   ~/pyro $ rake test
class TestPyro
  # Tests the template(name: '...') helper and argument.
  #
  # Expects a <script> tag with the proper src attribute.
  def test_template_name
    tag = @helpers.template src: 'pods/index/template.hbs', name: 'index'
    assert_includes tag, 'template.js'
  end

  # Tests the template(src: '...') helper and argument.
  #
  # Expects a <script> tag with the proper src attribute.
  def test_template_src
    tag = @helpers.template src: 'pods/application/template.hbs'
    assert_includes tag, 'template.js'
  end

  # Tests the template(prod_dir: '...') helper and argument.
  #
  # * Temporarily switches to the production environment.
  #
  # Expects a <script> tag with the proper src attribute.
  def test_prod_dir
    app.set :environment, :production
    tag = @helpers.script prod_dir: 'pods', target: 'js/pods.js'
    assert_includes tag, 'js/pods.js'
  end

  # Tests the test_template() helper.
  #
  # Expects a <script> tag with the proper src attribute.
  def test_test_template
    tag = @helpers.test_template dir: 'pods', target: 'js/test_templates.js'
    assert_includes tag, 'js/test_templates.js'
  end
end